<?php
/* [DoYouHaoBaby!] (C)Dianniu From 2010.
   this($)*/

!defined('DYHB_PATH') && exit;

class TemplateGtkGladeWidgetCompiler_GtkButton extends TemplateGtkGladeWidgetCompiler_GtkContainer{

	protected function compileCreateWidget_(TemplateGtkGladeWidget $oObject){
		$sWidgetClass=$oObject->getWidgetClass();
		$sVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oObject);
		$sCompiled="\t\t{$sVariableName}=new {$sWidgetClass}();";
		if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('use_stock'))){// stock 图标按钮
			$sCompiled.="\t\t{$sVariableName}->set_use_stock(true);";
			// 图标位置
			/*if($sImagePosition=($oObject->getProperty('image_position'))){

				$sImagePosition=str_replace('GTK_','Gtk::',$sImagePosition);
				$sCompiled.="\t\t{$sVariableName}->set_use_underline(true);\r\n";
			}*/
		}
		else{// 普通按钮
			if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('use_underline'))){$sCompiled.="\t\t{$sVariableName}->set_use_underline(true);";}// 使用下划线
		}
		if($sLabel=$oObject->getProperty('label')){$sCompiled.="\t\t{$sVariableName}->set_label('{$sLabel}');";}// 标签
		if($sRelief=$oObject->getProperty('relief')){// 使用下划线
			$sRelief=str_replace('GTK_','Gtk::',$sRelief);
			$sCompiled.="\t\t{$sVariableName}->set_relief({$sRelief});";
		}
		if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('focus_on_click'))===false){$sCompiled.= "\t\t{$sVariableName}->set_focus_on_click(false);";}// 点击时获得焦点
		$nXAlign=($nXAlign=$oObject->getProperty('xalign'))===null?0.5:floatval($nXAlign);// 按钮内元素（label或图） 排列布局
		$nYAlign=($nYAlign=$oObject->getProperty('yalign'))===null?0.5:floatval($nYAlign);
		if($nXAlign!=0.5 or $nYAlign!=0.5){$sCompiled.="\t\t{$sVariableName}->set_alignment({$nXAlign}, {$nYAlign});";}
		return $sCompiled;// 回应ID&response_id
	}

	static public function regToProcessorManager(ITemplateObjProcessorManager $oManager){
		$oManager->regProcessor(str_replace('TemplateGtkGladeWidgetCompiler_','',__CLASS__),__CLASS__);
	}

}
